package com.dh.spring.client.file.download;

import java.net.Socket;
import java.net.SocketException;

public class SocketDecorate {

    private static Socket _socket;
    public SocketDecorate() {}
    public static SocketDecorate getInstance(Socket socket) {
        _socket = socket;
        return new SocketDecorate();
    }

    private Socket getSocket(){
        return _socket;
    }

    public SocketDecorate setCustomTcpNoDelay(boolean on) throws SocketException {
        _socket.setTcpNoDelay(on);
        return this;
    }

    public SocketDecorate setCustomKeepAlive(boolean on) throws SocketException {
        _socket.setKeepAlive(on);
        return this;
    }

    public SocketDecorate setCustomSoLinger(boolean on, int linger) throws SocketException {
        _socket.setSoLinger(on, linger);
        return this;
    }

    public SocketDecorate setSendBuffer(int bytes) throws SocketException {
        _socket.setSendBufferSize(bytes);
        return this;
    }
}
